---
import { InterfaceDocumentation } from './InterfaceDocumentation';
import { getFrameworkFromPath } from '@components/docs/utils/urlPaths';
import { getInterfaceDocumentationModel } from '../utils/getInterfaceDocumentationModel';
import { getOverrides } from '../utils/getOverrides';
import { getJsonFile } from '@utils/pages';
import Code from '@ag-website-shared/components/code/Code';

const { interfaceName, overrideSrc, names, exclude, config } = Astro.props;

const framework = getFrameworkFromPath(Astro.url.pathname);

const overrides = await getOverrides(overrideSrc);
const interfaceLookup = getJsonFile('reference/interfaces.AUTO.json');
const codeLookup = getJsonFile('reference/doc-interfaces.AUTO.json');
const model = getInterfaceDocumentationModel({
    framework,
    interfaceName,
    overrides,
    names,
    exclude,
    config,
    codeLookup,
    interfaceLookup,
});
---

{
    model.type === 'code' ? (
        <Code code={model.code} keepMarkup={true} />
    ) : (
        <InterfaceDocumentation
            client:load
            interfaceName={interfaceName}
            framework={framework}
            model={model}
            config={{ ...config, hideHeader: config?.hideHeader ?? true }}
            isInline={true}
        />
    )
}
